function VARirplot_3New_CCP(IRFmed1,IRFmed2,IRFmed,pick,labels,filename,ordend2,INF1,SUP1,INF2,SUP2,FontSize)
% =======================================================================
% compare three different GIRFS 
%
% =======================================================================
% VARirplot_2(IRF1,IRF2,pick,labels,filename,INF1,SUP1,INF2,SUP2,FontSize)
% -----------------------------------------------------------------------
% INPUT
%   IRFmed1(:,:,:) : matrix with periods, variable, shock
%   IRFmed2(:,:,:) : matrix with periods, variable, shock
%
% OPTIONAL INPUT
%   pick     : a vector containing the shocks to be plotted [default 0 = all]
%   labels   : name of the variables, ordered as in the Cholesky
%   filename : name for file saving
%   INF1      : lower error band
%   SUP1      : upper error band
%   INF2      : lower error band
%   SUP2      : upper error band
%   Fontsize
% =======================================================================
% slightly modified (by Giovanni Pellegrino) on the basis of the function
% VARirplot by Ambrogio Cesa Bianchi, May 2012 (ambrogio.cesabianchi@gmail.com)


%% Check optional inputs & Define some parameters
%================================================
if ~exist('filename','var') 
    filename = 'shock_';
end

if ~exist('FontSize','var') 
    FontSize = 16;
end

% Initialize IRF matrix
[nsteps, nvars, nshocks] = size(IRFmed1);

% If one shock is chosen, set the right value for nshocks
if ~exist('pick','var') 
    pick = 1;
else
    if pick<0 || pick>nvars
        error('The selected shock is non valid')
    else
        if pick==0
            pick=1;
        else
            nshocks = pick;
        end
    end
end

% Define the rows and columns for the subplots
row = round(sqrt(nvars));
col = ceil(sqrt(nvars));

% Define a timeline
steps = 1:1:nsteps;
x_axis = zeros(1,nsteps);



%% Plot
%=========
% FigSize(24,8)
for jj = pick:nshocks                
    for ii=1:nvars
%         figure(jj)
        subplot(col,row,ii);
      %  set(gca,'XTick',[5 10 15 20])

         if exist('INF1','var') && exist('SUP1','var')
%             plot(steps,INF1(:,ii,jj),'LineStyle','-','Color',rgb('light blue'),'LineWidth',1);
%             hold on
%             plot(steps,SUP1(:,ii,jj),'LineStyle','-','Color',rgb('light blue'),'LineWidth',1);
 
      plot1=shadedplot(steps,INF1(:,ii,jj)',SUP1(:,ii,jj)',[0.7 0.7 0.7],[0.7 0.7 0.7] );
      set(gca,'XTickLabelMode', 'manual','XTickLabel',{'5','10','15','20'},'XTick',[5 10 15 20])
% grpyat=[steps', INF1(:,ii,jj); (nsteps:-1:1)' SUP1(:,ii,jj)];
% plot1=patch(grpyat(:,1), grpyat(:,2), [0.8 0.8 0.8],'edgecolor', [0.8 0.8 0.8]);
%          hAnnotation = get(plot1,'Annotation');
%         hLegendEntry = get(hAnnotation','LegendInformation');
%        set(hLegendEntry,'IconDisplayStyle','off')
hold on
          plot1=plot(steps,INF1(:,ii,jj),'LineStyle','-','Color',rgb('dark blue'),'LineWidth',1);
        hAnnotation = get(plot1,'Annotation');
        hLegendEntry = get(hAnnotation','LegendInformation');
        set(hLegendEntry,'IconDisplayStyle','off')
            hold on
            plot1=plot(steps,SUP1(:,ii,jj),'LineStyle','-','Color',rgb('dark blue'),'LineWidth',1);
         hAnnotation = get(plot1,'Annotation');
        hLegendEntry = get(hAnnotation','LegendInformation');
        set(hLegendEntry,'IconDisplayStyle','off')

       
         hold on
          plot1=plot(steps,INF2(:,ii,jj),'LineStyle','-','Color',rgb('red'),'LineWidth',1.5);
        hAnnotation = get(plot1,'Annotation');
        hLegendEntry = get(hAnnotation','LegendInformation');
        set(hLegendEntry,'IconDisplayStyle','off')
            hold on
            plot1=plot(steps,SUP2(:,ii,jj),'LineStyle','-','Color',rgb('red'),'LineWidth',1.5);
         hAnnotation = get(plot1,'Annotation');
        hLegendEntry = get(hAnnotation','LegendInformation');
        set(hLegendEntry,'IconDisplayStyle','off')
         end
        hold on
        plot1=plot(x_axis,'k','LineWidth',0.5);
        hAnnotation = get(plot1,'Annotation');
        hLegendEntry = get(hAnnotation','LegendInformation');
        set(hLegendEntry,'IconDisplayStyle','off')
        
        hold on 
        p2=plot(steps,IRFmed1(:,ii,jj),'LineStyle','-','Color',rgb('dark blue'),'LineWidth',2.5);
        hold on
        p3=plot(steps,IRFmed2(:,ii,jj),'LineStyle','--','Color',rgb('red'),'LineWidth',2.5);
        p4=plot(steps,IRFmed(:,ii,jj),'Marker','*','Color',rgb('green'),'LineWidth',1.5);
        hold on
        
        xlim([1 nsteps]);
        if exist('labels','var') 
            title(labels(ii),'FontSize',FontSize); 
        end
%         xlabel('Place your label here');
%         ylabel('Place your label here');
%         FigFont(FontSize);
    end
    if exist('labels','var')
       %  SupTitle( ['GIRF - Shock to ' char(labels(jj)) ' equation '] ); %. solid blue:low uncertainty , dashed red:high uncertainty ' 
    end

%     % Save
%     set(gcf, 'Color', 'w');
%     FigName = [filename num2str(jj)];
%     export_fig(FigName,'-pdf','-png','-painters')
%     clf('reset');
end
legend([p2 p3 p4],{'Normal times','ZLB','Nested linear VAR'});  

% close all